package com.example.yrdev.ordering_system.Report;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.example.yrdev.ordering_system.Common.CommonActivity;
import com.example.yrdev.ordering_system.CustomView.TimeDatePicker;
import com.example.yrdev.ordering_system.R;

import java.io.Serializable;
import java.util.Date;


/**
 * Created by yrdev on 8/31/16.
 */
public class OtherInfoReportActivity extends CommonActivity {

    Date startDate=new Date();
    Date endDate=new Date();
    int type;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.other_info_report_layout);
        showBackButton();
        initView();


    }

    public void initView() {

        Serializable value = getIntent().getSerializableExtra("class");
        type = Integer.parseInt(value.toString());
        switch (type) {
            case R.drawable.report_refund_detail:
                setBarTitle("退货明细");
                break;
            case R.drawable.report_sale_type:
                setBarTitle("商品消费明细");
                break;
            case R.drawable.report_total_report:
                setBarTitle("总报表");
                break;


        }

        TimeDatePicker timeDatePicker = new TimeDatePicker(this, "开始日期", false);
        timeDatePicker.setCallback(new TimeDatePicker.Callback() {
            @Override
            public void getDate(Date date) {
                startDate = date;

            }
        });
        getSupportFragmentManager().beginTransaction().add(R.id.start_date, timeDatePicker).commit();

        TimeDatePicker endTimeDatePicker = new TimeDatePicker(this, "截止日期", false);
        endTimeDatePicker.setCallback(new TimeDatePicker.Callback() {
            @Override
            public void getDate(Date date) {
                endDate = date;
            }
        });
        getSupportFragmentManager().beginTransaction().add(R.id.end_date, endTimeDatePicker).commit();
    }

    public void showDialog(View v){
        ReportDialog reportDialog=new ReportDialog(this,type);
        reportDialog.show();

    }


    //弹出来报表的dialog
    static class ReportDialog extends Dialog{
        int type;


        ReportDialog(Context context,int type){
            super(context);
            setTitle("报表结果");


            this.type=type;

        }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            initView();

        }
            public  void initView(){
                switch (type){
                    case R.drawable.report_total_report:
                        setContentView(R.layout.overall_report_layout);//总报表
                        break;

                    case  R.drawable.report_refund_detail:

                        setContentView(R.layout.report_refund_detail_layout);

                        break;


                }
            }
    }
}
